$(function(){
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd',
	    autoclose: true,
	    minuteStep: 1,
	    minView: "month"
	});
});

//加载玩家礼物赠送记录数据
function loadDatas(s){
	
	if(s=="search"){
		$("#page").val("");
	}

	//页码
	var page = $("#page").val();
	//一页显示的条数
	var pageSize = 40;
	//开始时间
	var begin = $("#begin_time").val();
	//结束时间
	var end = $("#end_time").val();
	//推广号
	var gameId = $("#gameId").val();
	//充值类型
	var czType = $("#czType").val();
	//用户类型
	var userType = $("#userType").val();
	//是否首充
	var sfsc = $("#sfsc").val();
	//游戏平台
	var gamePlatform = $("#gamePlatform").val();
	//订单号
	var no = $("#no").val();
	
	$.ajax({
		type: "post",
		data: {"page":page, "pageSize":pageSize, "begin":begin, "end":end, "gameId":gameId, "czType":czType, "userType":userType, "sfsc":sfsc, "gamePlatform":gamePlatform, "no":no},
		url: "../../php/player/playerInfo/loadPlayerChongZhiData.php",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			
//			console.log(msg);
			//统计数据
			var countInfo = msg.countInfo;
			$("#allCZ").html(countInfo[0].allScore == "" ? 0 : countInfo[0].allScore);
			$("#allCZUser").html(countInfo[0].allUser == "" ? 0 : countInfo[0].allUser);
			
			//表格数据
			var datas = msg.records;
			var html = "";
			if(datas.length == 0){
				html += "<tr><td colspan='11' align='center'>没查询到符合条件的数据~</td></tr>";
			}else{
				for(var i = 0; i<datas.length; i++){
					html += "<tr>";
					html += "<td>"+datas[i].transactionId+"</td>";//订单号
					html += "<td><a style='color:blue' href='./playerInfo/playerDetailsInfo.php?gameId="+datas[i].gameId+"' title='查看玩家详情'>"+datas[i].gameId+"</a></td>";//推广号
					html += "<td><a style='color:blue' href='./playerInfo/playerDetailsInfo.php?gameId="+datas[i].gameId+"' title='查看玩家详情'>"+datas[i].nickName+"</a></td>";//昵称
					html += "<td>"+datas[i].regIp+"</td>";//注册IP
					html += "<td>"+datas[i].lastLoginIp+"</td>";//登录IP
					var amount = datas[i].amount;//购买数量
					var danjia = datas[i].unitRMB;//单价
					html += "<td>"+(amount * danjia)+"</td>";//充值金额
					html += "<td>"+amount+"</td>";//购买数量
					html += "<td>"+datas[i].getGold+"</td>";//获得金币
					html += "<td>"+datas[i].logTime+"</td>";//充值时间
					html += "<td>"+datas[i].buyTypeName+"</td>";//充值类型
					//是否首充
					var first = datas[i].firstCharge;
					if(first == "1"){
						html += "<td>首充</td>";
					}else{
						html += "<td>非首充</td>";
					}
					html += "</tr>";
				}
			}
			$("#databody").html(html);
			
			//分页数据
			var pageInfos = msg.pageInfo;
			//总条数
			var allCount = pageInfos[0].count;
			$("#count").html(allCount);
			//总页数
			var allPage = Math.ceil(allCount/pageSize);
			if(allPage==0){
				allPage = 1;
			}
			//当前页码
			var now = pageInfos[0].page;
			
			$("#page").val(now);
			$("#nowPage").html(now);
			$("#allPage").html(allPage);
			$("#pageIpu").val("");
		}
	});
}